<!--
@description ：小程序
-->

<template>
  <div class="app-container">
    <div class="header-search">
      <NormalForm :formList="formList" :isShowCard="false" :operateForm="queryForm" pageTitle="小程序"
                  @handleQuery="handleQuery" @handleReset="handleReset" @specialSearch="handleQuery"></NormalForm>
    </div>
    <div class="set-content">
      <div style="text-align: right; margin: 12px 0;">
        <el-button icon="el-icon-plus" type="primary"
                   @click="$router.push({path:'createSmallProgram', query:{flag: '1'}})">创建小程序
        </el-button>
      </div>
      <div class="program-content">
        <div v-for="(item,index) in programList" :key="index" style="margin: 0 0 0 22px">
          <div class="content-item">
            <div class="content-item-header">
              <svg-icon icon-class="pro_home" style="font-size: 18px"></svg-icon>
              <el-popover :content="item.name" placement="top-start" trigger="hover" width="400" v-if="item.name.length > 11">
              <div slot="reference" class="table-desc overflow-ellipsis content-item-header-name">
               {{ item.name }}
              </div>
            </el-popover>
              <span class="content-item-header-name" v-else>
                {{item.name}}
              </span>
            </div>
            <div class="content-item-img">
              <img :src="item.pictureUrl" alt="">
            </div>
            <div class="content-item-bot">
              <div>
                <svg-icon icon-class="program" style="font-size: 16px"></svg-icon>
                <span style="margin-left: 4px">小程序</span>
              </div>
              <div>
                <svg-icon icon-class="pro_con" style="font-size: 20px;margin-right: 6px; cursor: pointer"
                          @click="$router.push({path:'smallProgramPath', query:{id: item.smallId}})"></svg-icon>
                <svg-icon icon-class="pro_edit" style="font-size: 18px; cursor: pointer"
                          @click="$router.push({path:'createSmallProgram', query:{flag: '2', id: item.smallId}})"></svg-icon>
              </div>
            </div>
          </div>
        </div>
      </div>
      <NormalPagination :currentPage="queryForm.pageNum" :pageSize="queryForm.pageSize" :total="total"
                        @handleCurrentChange="getListFn"
                        @handleSizeChange="getListFn"></NormalPagination>
    </div>
  </div>
</template>
<script>

import {queryProgramList} from "@/api/smallProgram";

export default {
  name: "smallProgram", //小程序
  props: {},
  components: {},
  data() {
    return {
      formList: [
        {
          label: '小程序',
          value: '',
          prop: 'name',
          type: 'INPUT',
          emunName: ''
        },
      ],
      queryForm: {
        name: '',
        pageNum: 1,
        pageSize: 20,
      },
      programList: [],
      total: 0,
    }
  },
  watch: {},
  methods: {
    // 查询
    handleQuery() {
      console.log('有触发吗')
      this.queryForm.pageNum = 1
      this.getListFn()
    },
    // 重置
    handleReset() {
      this.queryForm = {
        name: '',
        pageNum: 1,
        pageSize: 20,
      }
      this.getListFn()
    },
    getListFn() {
      let params = {
        ...this.queryForm
      }
      queryProgramList(params).then(res => {
        this.programList = res.rows
        this.total = res.total
      })
    },
  },
  mounted() {

  },
  created() {
    this.handleQuery()
  },
}

</script>

<style lang="scss" scoped>

.app-container {
  height: 100%;
  padding: 10px 0 0;
}

.header-search {
  padding: 10px;
  background-color: #fff;
  border-radius: 8px;
}

.set-content {
  //padding: 10px 16px;
  margin-top: 18px;
  background-color: #fff;
  border-radius: 8px;
  padding: 8px 12px 0 0;
}

.content-item {
  //width: 214px;
  background-color: #F8F8F8;
  border-radius: 8px;
  padding: 22px 14px 12px;
  margin: 22px 0 0 0;

  img {
    width: 204px;
    height: 234px;
  }
}

.program-content {
  display: flex;
  flex-wrap: wrap;

  .content-item-bot {
    margin: 12px 4px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;

    div {
      display: flex;
      align-items: center;
    }
  }

  .content-item-header {
    margin: 0 0 8px 0;
    display: flex;
    align-items: center;
  }

  .content-item-img {
    margin: 0;
  }

}

.content-item-header-name {
  max-width: 178px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-left: 8px;
}

</style>
